<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:zj="http://www.zju.edu.cn" exclude-result-prefixes="zj">
  <xsl:import href="../../Tk2Template/UpdateTemplate.xslt"/>
  <xsl:variable name ="RetURL" select ="$zj:Toolkit/URL/RetURL"/>
  
  <xsl:template name="zj:Post">   
    <script language="JavaScript">
      
      var source = "<xsl:value-of select="$zj:Source"/>";
      var url = "<xsl:value-of select="$zj:DSelfURL"/>";


      function FuncUpdate(save)
      {
      var guid = frmData._GUID.value;
      TabPost(url, guid, save);
      }

      function TabPost(webFile, dataSet, save)
      {
      var retURL = "<xsl:value-of select="$zj:DRetURL"/>";
      var tableNames = "<xsl:value-of select="$zj:XmlData/Toolkit/@Tables"/>";
      var fieldNames = "<xsl:value-of select="$zj:XmlData/Toolkit/@Fields"/>";
      if (retURL != ""){
      webFile += "&amp;RetURL=" + retURL;
      }

      PostDataWithCallBack(tableNames, fieldNames, webFile, dataSet, save,onInit, onSuccess, onError);
      }

      function onInit()
      {
     
      }

      function onSuccess(responseText)
      {
      var tabID = "easywebTabsDiv";
      var tab = $('#' + tabID).tabs('getSelected');
      var retURL = "<xsl:value-of select="$zj:RetURL"/>";
      $('#' + tabID).tabs('update',{
      tab: tab,
      options:{
      cache:false,
      href:retURL
      }
      });

      }

      function onError(){
      alert('error');
      }
    </script>
  </xsl:template>
  <xsl:template name="zj:Button">
    <xsl:call-template name="zj:SaveButton"/>
    <xsl:call-template name="zj:HRefButton">
      <xsl:with-param name="Name" select="'返回'"/>
      <xsl:with-param name="HRef" select="'#'"/>
      <xsl:with-param name="OnClick" select="concat('CancelButton(&quot;',$RetURL,'&quot;)')"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="zj:SaveButton">
    <xsl:call-template name="zj:SaveNoNewButton"/>   
  </xsl:template>
  <xsl:template name="zj:SaveNoNewButton">
    <xsl:call-template name="zj:JSButton">
      <xsl:with-param name="Name" select="' 保存'"/>
      <xsl:with-param name="JS" select="'FuncUpdate(&quot;save&quot;)'"/>
    </xsl:call-template>
  </xsl:template>
</xsl:stylesheet>
